package com.cw.jeeyt.dao.impl.process;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.cw.jeeyt.common.Order;
import com.cw.jeeyt.dao.intf.process.ProcessLeaveDao;
import com.cw.jeeyt.dao.mapper.process.ProcessLeaveMapper;
import com.cw.jeeyt.dao.model.process.ProcessLeaveDo;
import com.cw.lang.common.utils.PageUtil;
import com.cw.lang.common.pagehelper.PageHelper;
import com.cw.lang.mybatis.dto.PageInfo;

/**
 * 请假流程 dao数据库操作接口
 *
 * @author chenw
 * @date 2019-03-10 20:55:56
 */
@Repository
public class ProcessLeaveDaoImpl implements ProcessLeaveDao {
    @Autowired
    private ProcessLeaveMapper processLeaveMapper;

    /**
     * 新增请假流程
     *
     * @param processLeave
     * @return 整数
     */
    public Integer insert(ProcessLeaveDo processLeave) {
        return processLeaveMapper.insert(processLeave);
    }

    /**
     * 新增请假流程不为空的字段
     *
     * @param processLeave
     * @return 整数
     */
    public Integer insertSelective(ProcessLeaveDo processLeave) {
        return processLeaveMapper.insertSelective(processLeave);
    }

    /**
     * 删除请假流程
     *
     * @param processLeave
     */
    public void delete(ProcessLeaveDo processLeave) {
        processLeaveMapper.delete(processLeave);
    }

    /**
     * 修改请假流程不为null的字段
     *
     * @param processLeave
     */
    public void updateSelective(ProcessLeaveDo processLeave) {
        processLeaveMapper.updateSelective(processLeave);
    }

    /**
     * 修改请假流程
     *
     * @param processLeave
     */
    public void update(ProcessLeaveDo processLeave) {
        processLeaveMapper.updateSelective(processLeave);
    }

    /**
     * 根据主键查询请假流程
     *
     * @return 请假流程
     */
    public ProcessLeaveDo getById(String id) {
        return processLeaveMapper.getById(id);
    }

    /**
     * 查询所有请假流程
     *
     * @return 请假流程集合
     */
    public List<ProcessLeaveDo> queryProcessLeaveList() {
        return processLeaveMapper.queryProcessLeaveList();
    }

    /**
     * 分页查询请假流程
     *
     * @param processLeave 查询条件
     * @param startNum 开始条数
     * @param pageSize 每页长度
     * @return 请假流程集合
     */
    public PageInfo<ProcessLeaveDo> queryByPage(ProcessLeaveDo processLeave, Integer startNum, Integer pageSize,
        Order order) {
        PageHelper.startPage(PageUtil.calPageNum(startNum, pageSize), pageSize);
        return new PageInfo<>(processLeaveMapper.queryByPage(processLeave, order));
    }

    /**
     * 更新部门领导审批意见
     *
     * @param leave
     * @return
     */
    public int updateLeadText(ProcessLeaveDo leave) {
        return processLeaveMapper.updateLeadText(leave);
    }

    /**
     * 更新Hr意见
     *
     * @param leave
     * @return
     */
    public int updateHRText(ProcessLeaveDo leave) {
        return processLeaveMapper.updateHRText(leave);
    }
}
